package yuanyuan;

/**
 * @Author YuanYuan
 * @Date 2022/5/14
 * @Time 12:56
 */
class Animal {
    public String name;
    public int age;
    static {
        System.out.println("Animal的静态代码块！");
    }
    {
        System.out.println("Animal的实例代码块！");
    }
    public Animal() {
        System.out.println("Animal不带参数的构造方法！");
    }
    public Animal(String name,int age) {
        this.name = name;
        this.age = age;
    }

    public void eat() {
        System.out.println(name+"正在吃饭！");
    }
}
class Dog extends Animal{
    public float weight;

    static {
        System.out.println("Dog的静态代码块！");
    }

    {
        System.out.println("Dog的实例代码块！");
    }

    public Dog() {
        //super();
        //this(10.5); //这里也不可以有this()
        System.out.println("Dog不带参数的构造方法！");
    }

    public Dog(String name,int age,float weight) {
        //this(10.5); this  和 super  不能共存
        super(name,age);//显示的调用父类的构造函数，来初始化此时子类继承过来的父类的属性
        this.weight = weight;
    }

    public Dog(float weight) {
        super("hhh",10);
    }

    public void bark() {
        System.out.println(name+" 正在汪汪汪！");
    }
}

class Cat extends Animal{

    public Cat(String name, int age) {
        super(name, age);
    }

    public void miaomiao() {
        System.out.println(name+" 正在喵喵喵！");
    }
}



public class TestDemo {
    public static void main(String[] args) {
        Dog dog = new Dog();
        System.out.println("==================");
        Dog dog2 = new Dog();

    }
}
